package com.asa.navigationdempo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.asa.navigationdempo.databinding.FragmentNavcontainerBinding

class NavContainerFragment:Fragment() {


    private lateinit var binding:FragmentNavcontainerBinding
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentNavcontainerBinding.inflate(inflater,container,false)
        return binding.root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val textView = view.findViewById<TextView>(R.id.tv_a)
        val textViewB = view.findViewById<TextView>(R.id.tv_b)
        textView.setOnClickListener {
//            findNavController().navigate(R.id.fragment_a,Bundle().apply {
//                putSerializable("student",Student("张三",12,1))
//            })
            findNavController().navigate(NavContainerFragmentDirections.actionToChildFragmentA(Student("张三",45,12)))
        }
        textViewB.setOnClickListener {
            findNavController().navigate(R.id.fragment_b,Bundle().apply { putString("age","23") })
        }

    }




}